package com.konsung.util;

import android.content.Intent;

import com.konsung.util.constant.GlobalConstant;

/**
 * 类功能：用于发送广播
 */

public class BroadcastUtils {
    //自动上传
    public static final String AUTOUPLOAD = "com.konsung.healthfile.autouploadreceiver";
    //首次登陆的时候，启动管理软件发送广播启动自动上传服务
    public static final String START_AUTOUP_SERVICE = "com.konsung.healthfile.startserver";
    //登陆成功
    public static final String ON_LOGIN_SUCCESS = "com.konsung.startmanager.loginsuccess";
    //网络切换
    public static final String NETWORK_CHANGE = "android.net.conn.CONNECTIVITY_CHANGE";
    //当前居民发生改变
    public static final String REPLACE_PATIENT = "com.konsung.healthfile.replacepatient";
    //关闭窗口
    public static final String DISMISS_HEALTHFILE = "com.konsung.healthfile.dismiss";
    //显示窗口
    public static final String SHOW_HEALTHFILE = "com.konsung.healthfile.show";
    public static final String SHOW_ADDPATIENT = "com.konsung.addpatient.show";
    public static final String DISMISS_ADDPATIENT = "com.konsung.addpatient.dismiss";
    public static final String DARK_WINDOW = "com.konsung.startmanager.window.dark"; //变暗
    public static final String NORMAL_WINDOW = "com.konsung.startmanager.window.normal"; //窗口正常
    //健康档案软件界面显示的广播 用于内置刷卡服务
    public static final String HEALTH_FILE_ONSTART = "com.konsung.healthfile.onstart";
    //健康档案软件离开界面的广播 用于内置刷卡服务
    public static final String HEALTH_FILE_ONSTOP = "com.konsung.healthfile.onstop";
    //健康测量读取到刷卡数据的广播
    public static final String HEALRH_MEASURE_CARD_READER = "com.konsung.healthmeasure.cardreader";
    public static final String CARD_READER = "com.konsung.healthfile.cardreader";
    public static final String ADD_PATIENT = "com.konsung.healthfile.addpatientsuccess";
    public static final String ON_UPLOAD = "com.konsung.healthfile.onupload";
    public static final String UPLOAD_SUCCESS = "com.konsung.healthfile.uploadsuccess";
    public static final String SHOW_START_MANAGER = "com.konsung.startmanager.window.show";
    //正在更新数据库
    public static final String HEALTH_FILE_UPLOAD_DB = "com.konsung.healthfile.upload.db";
    //数据库更新完成
    public static final String HEALTH_FILE_UPLOAD_DB_SUCCESS
            = "com.konsung.healthfile.upload.db.success";
    //提示重新刷新病人数据
    public static final String REFRSH_PATIENT = "com.konsung.refrsh.patient";
    //从下载页面返回，通知设置当前用户
    public static final String SET_CURRENT_PATIENT = "com.konsung.set.current.patient";
    //点击了上传报告从体检报告列表页返回，通知刷新体检列表当前页数据
    public static final String REFRESH_MEASURE_LIST = "com.konsung.refresh.measure.list";
    //体检报告列表删除记录，通知刷新首页测量记录显示数据
    public static final String REFRESH_NEW_DATA = "com.konsung.refresh.new.data";
    /**
     * 通知应用更新，正在上传数据
     */
    public static void sendOnUploadForAppUpdate() {
        UiUtils.getContent().sendBroadcast(new Intent(ON_UPLOAD));
    }
    /**
     * 通知应用更新，上传数据结束
     */
    public static void sendOnUploadSuccessForAppUpdate() {
        UiUtils.getContent().sendBroadcast(new Intent(UPLOAD_SUCCESS));
    }
    /**
     * 通知健康测量，离开界面
     */
    public static void sendOnStopForHealthMeasure() {
        Intent intent = new Intent(HEALTH_FILE_ONSTOP);
        intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
        UiUtils.getContent().sendBroadcast(intent);
    }

    /**
     * 通知健康测量，启动界面
     */
    public static void sendOnStartForHealthMeasure() {
        Intent intent = new Intent(HEALTH_FILE_ONSTART);
        intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
        UiUtils.getContent().sendBroadcast(intent);
    }
    /**
     * 通知启动管理软件，窗口显示
     */
    public static void sendShowForStartManage() {
        UiUtils.getContent().sendBroadcast(new Intent(SHOW_HEALTHFILE));
    }

    /**
     * 通知启动管理软件，窗口隐藏
     */
    public static void sendHideForStartManage() {
        UiUtils.getContent().sendBroadcast(new Intent(DISMISS_HEALTHFILE));
    }
    /**
     * 通知启动管理软件，窗口变暗
     */
    public static void sendDarkForStartManage() {
        UiUtils.getContent().sendBroadcast(new Intent(DARK_WINDOW));
    }
    /**
     * 通知启动管理软件，窗口正常显示
     */
    public static void sendNormalForStartManage() {
        UiUtils.getContent().sendBroadcast(new Intent(NORMAL_WINDOW));
    }

    /**
     * 通知所有软件，当前居民发生改变
     */
    public static void sendReplacePatientForAll() {
        UiUtils.getContent().sendBroadcast(new Intent(REPLACE_PATIENT));
    }
    /**
     * 通知所有健康档案首页，新增居民
     */
    public static void sendAddPatientSuccess() {
        UiUtils.getContent().sendBroadcast(new Intent(ADD_PATIENT));
    }

    /**
     * 通知设置当前用户
     */
    public static void sendSetCurrentPatientSuccess() {
        UiUtils.getContent().sendBroadcast(new Intent(SET_CURRENT_PATIENT));
    }

    /**
     * 通知所有健康档案首页，打开新增居民窗口
     */
    public static void sendShowAddPatient() {
        UiUtils.getContent().sendBroadcast(new Intent(SHOW_ADDPATIENT));
    }
    /**
     * 通知所有健康档案首页，关闭新增居民窗口
     */
    public static void sendDismissAddPatient() {
        UiUtils.getContent().sendBroadcast(new Intent(DISMISS_ADDPATIENT));
    }
    /**
     *显示启动管理窗口
     */
    public static void sendStartManager() {
        UiUtils.getContent().sendBroadcast(new Intent(SHOW_START_MANAGER));
    }

    /**
     * 通知体检报告列表页面刷新数据
     */
    public static void sendRefreshMeasures() {
        UiUtils.getContent().sendBroadcast(new Intent(REFRESH_MEASURE_LIST));
    }

    /**
     * 通知新增界面，接收刷卡数据
     * @param address 地址
     * @param idcard 身份证号码
     * @param name 姓名
     * @param headPic 头像字节数组
     */
    public static void sendReadCardForAdd(String idcard, String name, String address
            , byte[] headPic) {
        Intent intent = new Intent(CARD_READER);
        intent.putExtra(GlobalConstant.IDCARD, idcard);
        intent.putExtra(GlobalConstant.NAME, name);
        intent.putExtra(GlobalConstant.ADDRESS, address);
        intent.putExtra(GlobalConstant.PICTURE, headPic);
        UiUtils.getContent().sendBroadcast(intent);
    }
    /**
     * 通知正在更新数据库
     */
    public static void sendUploadDB() {
        Intent intent = new Intent(HEALTH_FILE_UPLOAD_DB);
        UiUtils.getContent().sendBroadcast(intent);
    }
    /**
     * 通知数据库更新完成
     */
    public static void sendUploadDbSuccess() {
        Intent intent = new Intent(HEALTH_FILE_UPLOAD_DB_SUCCESS);
        UiUtils.getContent().sendBroadcast(intent);
    }

    /**
     * 通知重新刷新病人状态
     */
    public static void sendRefrshPatient() {
        Intent intent = new Intent(REFRSH_PATIENT);
        UiUtils.getContent().sendBroadcast(intent);
    }



}
